{if !isset($brief)}
{assign var='brief' value=false}
{/if}
{if !isset($compact)}
{assign var='compact' value=false}
{/if}

<table class="results{if $compact==true} results_compact{/if}">


{* TABLE HEADER *}
<tr>
{if $brief==false}
    <th>Entry Key</th><th>&nbsp;&nbsp;&nbsp;Authors&nbsp;&nbsp;&nbsp;</th><th>Title</th>
{else}
    <th>&nbsp;&nbsp;&nbsp;Author(s)&nbsp;&nbsp;&nbsp;</th><th>Title</th>
{/if}

{if isset($results[0].meta)}
<th>Meta Value</th>
{/if}
</tr>


{* SEARCH RESULT ROWS *}
{section name=results loop=$results}

    {if count($results[results].error) > 0}
	<tr link="index.php?p=view&ID={$results[results].ID}" class="{cycle values="rowalt1,rowalt2"}_error">
    {else}
	<tr link="index.php?p=view&ID={$results[results].ID}" class="{cycle values="rowalt1,rowalt2"}">
    {/if}
    
    {if $brief==false}
		<td><code>{$results[results].entrykey}</code>

        {if count($results[results].error) > 0}
            {html_table cols=1 rows=2 table_attr='border="0" style="font-size: smaller; font-weight: bold; color: #800;"' loop=$results[results].error}
        {/if}

</td>
    {/if}
		<td style="font-size: x-small; font-weight: bold;">
        {if $compact}
        {assign var="firstauthor" value=","|explode:$results[results].author[0]}
        {$firstauthor[0]}
        {else}
		{html_table cols=1 rows=2 table_attr='border="0"' loop=$results[results].author}
            {if count($results[results].author) > 2}
            &nbsp;<em>et al.</em>
            {/if}
        {/if}
		</td>
		<td width="100%">
		{if $results[results].filename != false && $user_loggedIn && $compact==false}
            <a href="uploads/{$results[results].filename}" class="filedownload">D</a>
		{/if}		
		{$results[results].title}
        {if $compact==false}
        <br /><em><strong>{$results[results].journal} ({$results[results].year})</strong></em>
        {/if}
		</td>
        {if isset($results[0].meta)}
        <td>{$results[results].meta}</td>
        {/if}
	</tr>
{/section}
{if count($results) == 0}
<tr><td colspan="10"><strong>No Entries Found</strong></td></tr>
{/if}
</table>


{if $compact==false}
<a href="index.php?p=bibtex&amp;q={urlencode val=$search_query}" class="export">Bibtex Export</a>
{/if}
